﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Store.IBLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Store_api.Controllers
{
    [Route("[controller]/[action]")]
    [ApiController]
    public class HomeController : ControllerBase
    {

        private readonly IUserManager _userManager;

        public HomeController(Store.IBLL.IUserManager userManager)
        {
            _userManager = userManager;
        }

        [HttpGet]
        public IActionResult Login(string LoginName, string pwd)
        {
            Guid userid;
            if (_userManager.Login(LoginName, pwd, out userid))
            {
                
                HttpContext.Session.SetString("Accout", userid.ToString());
                return new JsonResult(new { code = "200", message = "ok", data = userid });
            }
            else
            {
                return new JsonResult(new { code = "500", message = "用户名或密码有误！", data = "" });
            }
        }
    }
}
